package name.huzhenbo.java.patterns.templatemethod;


/**
 * Take a look at the generic type implementation at name.huzhenbo.java.klass.BubbleSorter
 */
public abstract class AbstractBubbleSorter {
    public int length;

    public void doSort() {
        for (int i = length - 1; i > 0; i--) {
            for (int j = 0; j < i; j++) {
                if (outOfOrder(j)) {
                    swap(j);
                }
            }
        }
    }

    public abstract void swap(int j);

    public abstract boolean outOfOrder(int j);
}
